package prueba4;


import java.sql.*;



public class Conectar {
    
   static String bd = "dbtaller"; 
   static String login = "grupo2"; 
   static String password = "grupo2"; 
   static String url = "jdbc:derby://localhost:1527/"+bd; 
 
   Connection con = null; 
       public Conectar() { 
      try{          
         Class.forName("org.apache.derby.jdbc.ClientDriver");          
         con = DriverManager.getConnection(url,login,password); 
         if (con!=null){ 
            System.out.println("Conección a base de datos "+bd+". listo"); 
         } 
      }catch(SQLException e){ 
         System.out.println(e); 
      }catch(ClassNotFoundException e){ 
         System.out.println(e); 
      } 
   } 
    
   public Connection getConnection(){ 
      return con; 
   } 
 
   public void desconectar(){ 
      con = null; 
   } 

    }

    

